package com.pmgames.store.components
{
	import mx.collections.ArrayCollection;
	import mx.controls.TextArea;

	public class TextComponent extends TextArea
	{
		public function TextComponent ()
		{
			super();
		}
		
		/***
		 *  set name, id, text 
		 */
		public function setIndicators(id:String, name:String, text:String = " "):void
		{
			this.id = id;
			this.name = name;
			this.text = text;
		}
		
		/***
		 * set size minHeight, minWidth, maxHeight, minHeight
		 */
		 public function setSize(height:int = -1, width:int = -1, minHeight:int = -1, minWidth:int = -1, maxHeight:int = -1, maxWidth:int = -1):void
		 {
		 	if(height > 0)
		 		this.height = height;
		 	if(width > 0)
		 		this.width = width;
		 	if(minHeight > 0)
		 		this.minHeight = minHeight;
		 	if(minWidth > 0)
		 		this.minWidth = minWidth;
		 	if(maxHeight > 0)
		 		this.maxHeight = maxHeight;
		 	if(maxWidth > 0)
		 		this.maxWidth = maxWidth;
		 }
		 
		 /***
		 * set TextComponent styles
		 * (ex. backgrowndAlpha, textAlign, fontWeight)
		 */
		 public function setStyles(styles:ArrayCollection, vals:ArrayCollection):void
		 {
		 	for(var index:int = 0; index < styles.length; index++)
		 	{
		 		this.setStyle(String(styles.getItemAt(index)), vals.getItemAt(index));
		 	}
		 }
		 
		 /***
		 * set TextComponent properties for TextArea to resemble Button
		 * (ex. editable, buttonMode, useHandCursor, mouseChildren)
		 */
		 public function resembleButton():void
		 {
		 	this.editable = false;
		 	this.buttonMode = true;
		 	this.useHandCursor = true;
		 	this.mouseChildren = false;
		 }
		 
		 /***
		 * add events
		 */
		 public function setEvents(events:ArrayCollection, funcs:ArrayCollection):void
		 {
		 	for(var index:int = 0; index < events.length; index++)
		 	{
		 		var func:Function = funcs.getItemAt(index) as Function;
		 		this.addEventListener(String(events.getItemAt(index)), func);
		 	}
		 }
		 
		 /***
		 * remove events
		 */
		 public function removeEvents(events:ArrayCollection, funcs:ArrayCollection):void
		 {
		 	for(var index:int = 0; index < events.length; index++)
		 	{
		 		var func:Function = funcs.getItemAt(index) as Function;
		 		this.removeEventListener(String(events.getItemAt(index)), func);
		 	}
		 }
		 
	}
}